include_guard()
include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
function(add_driver_ifdef CONFIG_SYMBOL target_name)
  set(options "")
  set(oneValueArgs SYSCALL_HEADER)
  set(multiValueArgs SOURCES PUBCLIC_INCLUDES )
  cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}"
                        ${ARGN})

  if(ARG_SYSCALL_HEADER)
    zephyr_syscall_header(${ARG_SYSCALL_HEADER})
  endif()

  zephyr_library_named(${target_name})
  zephyr_include_directories(include)
  if (ARG_SOURCES)
    zephyr_library_sources_ifdef(${CONFIG_SYMBOL} ${ARG_SOURCES})
  endif()
endfunction()

function(add_library_ifdef CONFIG_SYMBOL target)
  set(multiValueArgs SOURCES PUBLIC_INCLUDES PRIVATE_INCLUDES)
  zephyr_library_named(${target})
  target_include_directories(${target} PUBLIC include)
  target_include_directories(${target} PRIVATE include/internal)
  set(SRCS)
  foreach(src ${ARG_SOURCES})
    string(SUBSTRING ${src} 0 4 substring)
    if(NOT ${substring} STREQUAL "src/")
      list(APPEND SRCS src/${src})
    else()
      list(APPEND SRCS ${src})
    endif()
  endforeach()
  zephyr_library_sources_ifdef(${CONFIG_SYMBOL} ${SRCS})
endfunction()
